﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace GameBanChim_Version1
{
    public abstract class VisibleGameObject
    {
        private MySprite[] _sprite;

        public MySprite[] Sprite
        {
            get { return _sprite; }
            set { _sprite = value; }
        }

        private int _nsprite;

        public int Nsprite
        {
            get { return _nsprite; }
            set { _nsprite = value; }
        }

        private int _isprite;

        public int Isprite
        {
            get { return _isprite; }
            set { _isprite = value; }
        }

        Rectangle _rec;
        public Rectangle Rec
        {
            get { return _rec; }
            set { _rec = value; }
        }

        private float _x;

        public float X
        {
            get { return _x; }
            set 
            {
                _x = value; 
                // set hinh vuong cho toa do x:
                for (int i = 0; i < _nsprite; i++)
                {
                    _sprite[i].x = _x;
                }
                _rec = new Rectangle((int)_x, (int)_y, (int)_rec.Width, (int)_rec.Height);
            }
        }

        private float _y;

        public float Y
        {
            get { return _y; }
            set 
            {
                _y = value;
                // set hinh vuong cho toa do y:
                for (int i = 0; i < _nsprite; i++)
                {
                    _sprite[i].y = _y;
                }
                _rec = new Rectangle((int)_x, (int)_y, (int)_rec.Width, (int)_rec.Height);
            }
        }
        // hàm tạo 1 đối tượng
        public virtual bool Init(ContentManager Content, int index, string strResourceXML)
        {
            return false;
        }
        // hàm sao chép 1 đối tượng
        public virtual VisibleGameObject Clone()
        {
            return null;
        }
        // hàm update đối tượng
        public virtual void Update(GameTime gameTime)
        {
            //_sprite[_isprite].Update(gameTime);
            for (int i = 0; i < _nsprite; i++)
                _sprite[i].Update(gameTime);
        }
        // hàm vẽ đối tượng
        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            //_sprite[_isprite].Draw(gameTime, spriteBatch);
            for (int i = 0; i < _nsprite; i++)
                _sprite[i].Draw(gameTime, spriteBatch);
        }
    }
}
